Page({

  /**
   * 页面的初始数据
   */
  data: {
    background: [
      {src: '/static/swiper/1.jpg',status: true},
      {src: '/static/swiper/2.jpg',status: false},
      {src: '/static/swiper/3.jpg',status: false},
      {src: '/static/swiper/4.jpg',status: false},
      {src: '/static/swiper/5.jpg',status: false},
      {src: '/static/swiper/6.jpg',status: false},
    ],
    current: 1,
    timeEndShow: true,
    dataItem: {},
    commentList: [
      {
        oneInfoImg: '/static/no-avatar.png',
        id: 1,
        oneInfoName: '云卷云舒',
        oneInfoContent: '求图求图',
        oneInfoTime: '11-13',
        oneInfoCity: '浙江',
        light: true,
        isAuthor: false,
        oneReplyList: [
          {
            twoInfoImg: '/static/no-avatar.png',
            id: 11,
            twoInfoName: '作者彭不乐',
            twoInfoContent: '安排安排',
            twoInfoTime: '11-13',
            twoInfoCity: '海南',
            light: false,
            isAuthor: true,
          },
          {
            twoInfoImg: '/static/no-avatar.png',
            id: 12,
            twoInfoName: '千秋岁',
            twoInfoContent: '作者真棒',
            twoInfoTime: '11-13',
            twoInfoCity: '北京',
            light: false,
            isAuthor: false,
          },
          {
            twoInfoImg: '/static/no-avatar.png',
            id: 13,
            twoInfoName: '喜乐来',
            twoInfoContent: '从哪获取的图片呢',
            twoInfoTime: '11-13',
            twoInfoCity: '上海',
            light: false,
            isAuthor: false,
          }
        ]

      },
      {
        oneInfoImg: '/static/no-avatar.png',
        id: 2,
        oneInfoName: '云卷云舒',
        oneInfoContent: '求图求图',
        oneInfoTime: '11-13',
        oneInfoCity: '浙江',
        light: true,
        isAuthor: false,
        oneReplyList: [
          {
            twoInfoImg: '/static/no-avatar.png',
            id: 21,
            twoInfoName: '作者彭不乐',
            twoInfoContent: '安排安排',
            twoInfoTime: '11-13',
            twoInfoCity: '海南',
            light: false,
            isAuthor: true,
          },
          {
            twoInfoImg: '/static/no-avatar.png',
            id: 22,
            twoInfoName: '千秋岁',
            twoInfoContent: '作者真棒',
            twoInfoTime: '11-13',
            twoInfoCity: '北京',
            light: false,
            isAuthor: false,
          },
          {
            twoInfoImg: '/static/no-avatar.png',
            id: 23,
            twoInfoName: '喜乐来',
            twoInfoContent: '从哪获取的图片呢',
            twoInfoTime: '11-13',
            twoInfoCity: '上海',
            light: true,
            isAuthor: false,
          }
        ]

      },
      {
        oneInfoImg: '/static/no-avatar.png',
        id: 3,
        oneInfoName: '云卷云舒',
        oneInfoContent: '求图求图',
        oneInfoTime: '11-13',
        oneInfoCity: '浙江',
        light: false,
        isAuthor: false,
        oneReplyList: [
          {
            twoInfoImg: '/static/no-avatar.png',
            id: 31,
            twoInfoName: '作者彭不乐',
            twoInfoContent: '安排安排',
            twoInfoTime: '11-13',
            twoInfoCity: '海南',
            light: true,
            isAuthor: true,
          },
          {
            twoInfoImg: '/static/no-avatar.png',
            id: 32,
            twoInfoName: '千秋岁',
            twoInfoContent: '作者真棒',
            twoInfoTime: '11-13',
            twoInfoCity: '北京',
            light: false,
            isAuthor: false,
          },
          {
            twoInfoImg: '/static/no-avatar.png',
            id: 33,
            twoInfoName: '喜乐来',
            twoInfoContent: '从哪获取的图片呢',
            twoInfoTime: '11-13',
            twoInfoCity: '上海',
            light: false,
            isAuthor: false,
          }
        ]

      }
    ],
    windowClientHeight: 0,
    inputFocus: false,
    inputBottom: 0,
    inputTop: -60,
  },
  dataList(type) {
    var data = {
      userId: '1',
      dateType: type
    }
  },
  swiperChange(e) {
    const that = this
    that.setData({
      current: e.detail.current + 1,
      timeEndShow: true
    })
    setTimeout(() => {
      that.setData({
        timeEndShow: false
      })
    }, 5000)
  },
  flashInput(){
    this.setData({
      inputFocus: true,
    })
    
  },
  inputBindFocus(e) {
    let that = this
    let queryNodeHeight = 0
    wx.createSelectorQuery().select('.absolute_input').boundingClientRect().exec(function (res) {
      console.log('queryNode', res)
      queryNodeHeight = res[0].height
      that.setData({
        inputBottom: e.detail.height,
        inputTop: that.data.windowClientHeight - e.detail.height - queryNodeHeight,
        // inputBottom: 20,
        inputFocus: true,
      })
    })
  },
  inputBindBlur(e) {
    console.log('inputBindBlur', e)
    this.setData({
      inputBottom: 0,
      inputTop: -60,
      inputFocus: false,
    })
  },
  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    const that = this
    console.log('option', options, JSON.parse(options.item))
    this.setData({
      dataItem: JSON.parse(options.item)
    })
    wx.setNavigationBarTitle({
      title: that.data.dataItem.bigName,
    })
    setTimeout(() => {
      that.setData({
        timeEndShow: false
      })
    }, 5000)
    this.dataList('all')
    // 获取系统信息
    wx.getSystemInfo({
      success: function (res) {
        // 获取可使用窗口宽度
        let clientHeight = res.windowHeight;
        // 获取可使用窗口高度
        let clientWidth = res.windowWidth;
        // 算出比例
        let ratio = 750 / clientWidth;
        // 算出高度(单位rpx)
        let height = clientHeight * ratio;
        console.log('可使用窗口宽度', clientHeight)
        console.log('可使用窗口高度', clientWidth)
        console.log('算出高度(单位rpx)', height)
        that.setData({
          windowClientHeight: clientHeight
        })
      }
    });
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {

  }
})